﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

namespace OrderEntryProject
{
	public class LinqToSqlTraceWriter : TextWriter
	{
		private readonly BooleanSwitch _logSwitch;

		public LinqToSqlTraceWriter(String logSwitchString)
		{
			_logSwitch = new BooleanSwitch(logSwitchString, logSwitchString);
		}

		public override Encoding Encoding
		{
			get { throw new NotImplementedException(); }
		}

		public override void Close()
		{
			Trace.Close();
		}

		public override void Write(bool value)
		{
			if(_logSwitch.Enabled)
				Trace.Write(value);
		}

		public override void Flush()
		{
			Trace.Flush();
		}
	}
}
